package com.yingside.clazz.pattern;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestRegex {
    public static void main(String[] args) {
        //String str = "我爱中国, ,,中国爱我 ,,我爱四川  ,,,,,四川爱我";
//        String[] split = str.split("[\\s,]+");
//        for (int i = 0; i < split.length; i++) {
//            System.out.println("====" + split[i] + "====");
//        }

//        Pattern pattern = Pattern.compile("[\\s,]+");
//        String[] split = pattern.split("我爱中国, ,,中国爱我 ,,我爱四川  ,,,,,四川爱我");
//        for (int i = 0; i < split.length; i++) {
//            System.out.println("====" + split[i] + "====");
//        }


//        String str = "我爱中国 ,中国爱我, 中国人人爱";
//        String replace = str.replaceFirst("[\\s,]+", "-");
//        System.out.println("replace = " + replace);

//        String str = "abdgyiufcdffsdfb";
//        String replace = str.replace("ab", "x");
//        System.out.println("replace = " + replace);


        //String str = "abdgyiufcdffsdfb";
        // 贪婪(最大化)匹配
        //String reg = ".+b";
        //惰性匹配
        //String reg = ".+?b";
        //String x = str.replaceAll(reg, "x");
        //System.out.println("x = " + x);

//        String html = "<a href=\"index.html\">主页</a>";
//        String reg = "<.+?>";
//        String s = html.replaceAll(reg, "");
//        System.out.println("s = " + s);
    }




}
